package com.dgw.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dgw.entity.Student;
import com.dgw.mapper.StudentMapper;
import com.dgw.service.StudentService;
import com.dgw.utils.Page;
import com.dgw.utils.PageInfoToPageUtil;
import com.dgw.utils.PageRows;
import com.dgw.utils.StringUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Service
public class StudentServiceImpl implements StudentService{
	
	@Autowired
	private StudentMapper studentMapper;

	@SuppressWarnings("unchecked")
	public PageInfo<Student> selectByPageAndSelections(String keyword, PageRows pageRows) {
		PageHelper.startPage(pageRows.getCurrentPage(), pageRows.getPageSize());
		List<Student> students = studentMapper.selectByPageAndSelections(keyword);
		PageInfo<Student> pageInfo = new PageInfo<>(students);
		return pageInfo;
	}

	@Override
	public int insert(Student student) {
		student.setsId(StringUtil.uuid());
		return studentMapper.insert(student);
	}

	@Override
	public int updateByPrimaryKeySelective(Student student) {
		return studentMapper.updateByPrimaryKeySelective(student);
	}

	@Override
	public Student selectByPrimaryKey(String sId) {
		return studentMapper.selectByPrimaryKey(sId);
	}
}
